#import "BWHandTool.h"

#import "BWLayerView.h"

@implementation BWHandTool

- (BOOL) handleMouseDown: (NSEvent *) event
                 atPoint: (NSPoint) mouse
{
    // deal in window coordinates.  there is a scrolling problem
    // if using view coordinates
    grabOrigin = [event locationInWindow];
    
    NSClipView *contentView;
    contentView = (NSClipView*)[layerView superview];
    
    scrollOrigin = [contentView bounds].origin;

    return (YES);

} // handleMouseDown


- (void) handleMouseDragged: (NSEvent *) event
                    atPoint: (NSPoint) mouse
{
    NSPoint mousePoint;
    mousePoint = [event locationInWindow];
    
    float deltaX, deltaY;
    deltaX = grabOrigin.x - mousePoint.x;
    deltaY = mousePoint.y - grabOrigin.y;
    
    NSPoint newOrigin;
    newOrigin = NSMakePoint (scrollOrigin.x + deltaX,
                             scrollOrigin.y + deltaY);
    
    [layerView scrollPoint: newOrigin];

} // handleMouseDragged


- (NSArray *) affectedLayers
{
    return (nil);
} // affectedLayers

@end // BWHandTool


